package com.utilities.regex;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

public abstract class CookieTool {


    public static String resolveValue(String input,String name){
        String  regex="(^| |;)"+name+"=([^;]*)(;|$)";
        Matcher matcher = compileAndMatcher(input, regex);
        if(matcher.find()){
            return matcher.group(2);
        }
        return "";
    }
    public static String resolveValueV2(String input,String name){
        String  regex="(?:^| |;)"+name+"=([^;]*)(?:;|$)";
        Matcher matcher = compileAndMatcher(input, regex);
        if(matcher.find()){
            return matcher.group(1);
        }
        return "";
    }

    private static Matcher compileAndMatcher(String input, String regex) {
        Pattern compile = Pattern.compile(regex);
        return compile.matcher(input);
    }

    public static void main(String[] args) {




    }


}
